package edu.hhu.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.core.Controller;

import edu.hhu.chart.service.ChartDataService;

public class ChartController extends Controller {

	public void showChart() {

		List<String> fields = Arrays.asList(this.getPara("fieldStr").split(","));
		List<String> legend = Arrays.asList(this.getPara("nodeStr").split(","));
		Map<String,String> parameters = new HashMap<>();
		parameters.put("level",this.getPara("level"));
		parameters.put("chartType",this.getPara("chartType"));
		parameters.put("chartStyle",this.getPara("chartStyle"));
		parameters.put("normalType",this.getPara("normalType"));

		ChartDataService chartDataService = new ChartDataService();
		
		String json = chartDataService.getChartJson(fields, legend, parameters);
		System.out.println("json："+json);
		
		renderJson(json);
	}
}
